<?php
header('Content-type:Text/html; charset=utf-8');
@$login=$_POST['z'];
@$password=$_POST['m'];
if(empty($login) || empty($password)){ 
	header('Refresh:2;url=/z3.php');
	die('<h3>登录信息不完整</h3><a href="z3.php">返回重新登录</a>');
}
$pdo=new PDO('mysql:dbname=zc;charset=utf8','root');
$s=$pdo->prepare('select z,m from gly where z=:z');
$s->execute(array('z'=>$login));
$user=$s->fetch(PDO::FETCH_NAMED);
if(empty($user)){
	header('Refresh:2;url=/z3.php');
	die('<h3>登录名不存在</h3><a href="z3.php>返回重新登录</a>');	
}
if ($user['m']!=$password){
	header('Refresh:2;url=/z3.php');
	die('<h3>密码错误</h3><a href="z3.php>返回重新登录</a>');
}

unset($user['password']);
$user['z']=$login;

session_start();
$_SESSION['m1']=$user;

header('Refresh:2;url=/gl2.php');
die('<h3>登录成功</h3><a href="/gl2.php>访问主页</a>');